﻿@namespace SE.PO.CInterface.Web.Pages.DB.Room
@page "/db/rooms"
@using SE.PO.CInterface.Web.Clients
@using AutoMapper
@using SE.PO.CInterface.DBProtocols.Rooms
@inject RoomClient Client
@inject IMapper Mapper;
@inject INotificationService Notice
<PageContainer Title="机房">
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>首页</BreadcrumbItem>
            <BreadcrumbItem>数据库协议</BreadcrumbItem>
            <BreadcrumbItem>机房</BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <Content>
        <span>下级SC把监控对象配置根据“数据库接口定义”的数据结构存储到中间数据库表中，增加、修改和删除任何配置，下级SC必须保证能够及时的维护该中间数据库表中的数据。涉及到的中间数据库表有M_Area、M_Site、M_Room、M_Device、M_SIGNAL，M_SU，NodeModify，NodeUpdate。中间数据库表中的数据除了NodeUpdate外均由下级SC维护，下级SC保证上述表中的数据和下级SC的配置一致；NodeUpdate表由上级SC负责添加数据，下级SC定时获取数据并维护（删除）。</span>
    </Content>
    <ChildContent>
        <Card>
            <Button OnClick="@(() => { _addVisible = true; })" Type="primary" Style="margin-bottom:16px">
                新增机房
            </Button>
            <Button OnClick="@DeleteSelectedRows" Type="danger" Style="margin-bottom:16px">
                删除选定
            </Button>
            <Table @ref="_table"
                   TItem="RoomDto"
                   DataSource="@_source"
                   Total="_total"
                   @bind-PageIndex="_pageIndex"
                   @bind-PageSize="_pageSize"
                   @bind-SelectedRows="_selectedRows"
                   OnChange="OnChange"
                   Size="TableSize.Small">
                <Selection Key="@(context.Id)"/>
                <PropertyColumn Title="下级SCID" Property="c => c.ScId" />
                <PropertyColumn Title="机房编号" Property="c => c.Id" />
                <PropertyColumn Title="机房名称" Property="c => c.RoomName"/>
                <PropertyColumn Title="站点名称" Property="c => c.SiteName"/>
                <PropertyColumn Title="机房描述" Property="c => c.RoomDesc" />
                <PropertyColumn Title="机房类型" Property="c => c.DisplayRoomType" />
                <ActionColumn Width="160" Title="操作" Fixed="right">
                    <Space>
                        <SpaceItem>
                            <Button Danger OnClick="@(() => { _delVisible = true; Delete(context.Id);})">删 除</Button>
                        </SpaceItem>
                        <SpaceItem>
                            <Button OnClick="@(() => { _editVisible = true; Edit(context.Id);})">修 改</Button>
                        </SpaceItem>
                    </Space>
                </ActionColumn>
            </Table>
        </Card>
    </ChildContent>
</PageContainer>

<Modal Title="新增机房"
       Centered="true"
       Visible="@_addVisible"
       OnOk="@AddHandleOk"
       OnCancel="@AddHandleCancel">
    <AddRoomFrom @ref="_addFrom"
                 OnSuccess="async () => { _addVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                 OnFailure="() => { _addVisible = true; }"
                 OnCancel="() => { _addVisible = true; }" >
    </AddRoomFrom>
</Modal>

<Modal Title="编辑机房"
       Centered="true"
       Visible="@_editVisible"
       OnOk="@EditHandleOk"
       OnCancel="@EditHandleCancel">
    <EditRoomFrom @ref="_editFrom"
                  Model="@_editModel"
                  OnSuccess="async () => { _editVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                  OnFailure="() => { _editVisible = true; }"
                  OnCancel="() => { _editVisible = true; }">
    </EditRoomFrom>
</Modal>

<Modal Title="删除机房"
       Centered="true"
       Visible="@_delVisible"
       OnOk="@DeleteHandleOk"
       OnCancel="@DeleteHandleCancel">
    <DelRoomFrom @ref="_delFrom"
                 Model="DelModel"
                 Models="@DelModels"
                 OnSuccess="async () => { _delVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                 OnFailure="() => { _delVisible = true; }"
                 OnCancel="() => { _delVisible = true; }">
    </DelRoomFrom>
</Modal>